home *** CD-ROM | disk | FTP | other *** search
- vsyncon=0 ;switch on if you want vsync (no tearing visible)
- #scrolling=0 ;set to 1 if you check speed when you scroll the background
- optimize 7;
- ;A little demo of moving things using the Blit command...
- ; the image.res must inlcude in compileroptions to use this functions
- WBStartup
- ;create a 'ball' type variable
- ;
- NEWTYPE.ball
- x.q
- y
- xs
- ys
- End NEWTYPE
- DEFTYPE.l
- ;dimension a 'List' of 'balls'
-
-
- Dim List balls.ball(30)
- !image_include
- !screen_ {0,"","ram:prefsfile",1}:If scr\id=0 Then End ;for display
- Window 0,0,0,scr\width,scr\height,$800,"",0,1
- succ=image_load {1,"amiga1000.jpg"}
- succ=image_load {0,"ball.iff"}
-
- image_blit{1,0,0} ;to set the palette for 8bit screens
- InitShape 0,16,16,2
- WPointer 0 ;set a unvisible mousepointer
- !screen_ {1,"","ram:prefsfile",0}:If scr\id=0 Then End ;for render
- ;a second screen for doublebuffer
- Window 1,0,0,scr\width,scr\height,$800,"",0,1 ;second window
- !screen_ {2,"","ram:prefsfile",0}:If scr\id=0 Then End ;screen for background
-
- Window 2,0,0,scr\width,scr\height,$800,"",0,1 ;window to store backgroundimage
- image_blit{1,0,0} ;blit the backgroundimage in window
- ;keep adding items to list until list full
- ;
- While AddLast(balls())
- balls()\x=Rnd(scr\width-30)+15,Rnd(scr\height-30)+15,(Rnd-.5)*20+1,(Rnd-.5)*20+1
- Wend
-
- ShowScreen 0
-
- ;while mouse button not hit..
- ;
- While Joyb(0)=0
-
- If vsyncon VWait ;can enable if you dont like tearing
- ;but most time this is unvisibly
- Use Screen 1 ;copy all from screen 1 to window 0
- Use Window 0
- image_blitblock{0}
- CNIF #scrolling>0
- Use Window 2
- WScroll 0,0,scr\width,scr\height,1,1 ;scroll the background
- CEND
- Use Window 1 ;set the renderwindow to 1
- ;start at first item in list
- ;
- ResetList balls()
- ;WCls
- Use Screen 2 ;use the backgroundimage from screen 2
- ;screennum is source
- ;windowsnum is destination
- image_blitblock{0} ;blit whole backgroundimage
- WLocate 220,55
- If res<5 Then res=5
- CNIF #scrolling=0 ;use textbackgroundcolor when scroll to read fps better
- WJam 0 ;dont use textbackgroundcolor
- CEND
- NPrint "fps ",50/(res LSR 2)," ",num
-
- ;wait for vertical blank
- ;
- ;Delay_(1)
-
- ;while more items to come...
- ;
- While NextItem(balls())
- balls()\x+balls()\xs
- balls()\y+balls()\ys
- ;reverse direction if ball gets to edge of bitmap
- ;
- If balls()\x<10 OR balls()\x>scr\width Then balls()\xs=-balls()\xs
- If balls()\y<10 OR balls()\y>scr\height Then balls()\ys=-balls()\ys
- image_blitmask {0,balls()\x,balls()\y,1} ;draw balls
- 'l1 BTST #6,$dff016
- BEQ 'l1
- Wend
- count+1
- If count=4 Then count=0:res=Timer:ResetTimer
- Wend
- End ;important allow autofree
-